<template>
    <div class="wrapper">
		<div class="header">黑名单</div>
		<div class="content">
			<div class="list">
				<div class="list_wrapper" v-for="item in BlackListItem">
					<div class="list_item2">
						<div class="list_item2_left"><img src="img/face.png" @click.stop="friendDetail(item.To_Account)"></div>
						<div class="list_item2_right">
							<span class="friend_name">{{item.To_Account}}</span>
							<span class="friend_desc"></span>
						</div>
						<div @click.stop="deleteBlackList(item.To_Account)">取消拉黑</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import $ from 'jquery'
import Client from "../../config/common";
export default {
    data(){
        return{
			loginInfo:{},
			BlackListItem:[]

        }
    },
    created(){
		Client.login((loginInfo) => {
			 this.loginInfo = loginInfo;
			 this.getBlackList();
		});
	},
	mounted(){
        		
    },

    components:{
       // headTop
    },

    computed:{

    },

    methods:{
		friendDetail(id){
		    this.$router.push({path:'/friendDetail', query:{id}});
	    },
		getBlackList(cbOK, cbErr) {
			let options = {
				'From_Account': this.loginInfo.identifier,
				'StartIndex': 0,
				'MaxLimited': 100,
				'LastSequence': 0
			};
			webim.getBlackList(
					options,
					(resp) => {
						console.log(resp)
						this.BlackListItem = resp.BlackListItem;
					},
					(err) => {
						alert(err.ErrorInfo);
					}
			);
		},
		//删除黑名单
		deleteBlackList(del_account) {
			var options = {
				'From_Account': this.loginInfo.identifier,
				'To_Account': [del_account]
			};
			webim.deleteBlackList(
					options,
					resp => {
						//console.log(resp);
						this.deleteViewList(del_account);
						alert('删除黑名单成功');
					},
					err => {
						alert(err.ErrorInfo);
					}
			);
		},
		//删除视图对应列表名单
		deleteViewList(account){
		    //console.log(this.BlackListItem);
			this.BlackListItem.forEach((ele,i) => {
				if(ele.To_Account == account){
					this.BlackListItem.splice(i,1);
				}
			});
		}
    },
}

</script>

<style lang="scss"> 
   @import '../../style/black_list';
</style>